<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('COM_JHTRAQ_PROJECT_ADD_EDIT'), 'generic.png');
JToolBarHelper::save();
JToolBarHelper::cancel();
//JToolBarHelper::preferences('com_jhtraq');
$editor =& JFactory::getEditor();
?>
<?php JHTML::_('behavior.tooltip'); ?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&]", "i");
	
	// do field validation
	// removed the trim here because it was not working
	if (form.name.value == "") {
		alert( "<?php echo JText::_( 'COM_JHTRAQ_MUST_NAME', true ); ?>" );
	} else if (form.slug.value == "") {
		alert( "<?php echo JText::_( 'COM_JHTRAQ_MUST_SLUG', true ); ?>" );
	}else {
		submitform( pressbutton );
	}
}
</script>
<form action="index.php?option=com_jhtraq&view=projects" method="post" name="adminForm">
<input type="hidden" name="task" value="" />
<input type="hidden" name="id" value="<?php echo (int)@$this->project->id;?>" />

<table class="adminlist" cellpadding="1">
<tr>
	<td width="150"><label for="name"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_NAME_TT'), '', '', 'COM_JHTRAQ_PROJECT_NAME'); ?></label></td>
	<td><input type="text" name="name" id="name" value="<?php echo @$this->project->name;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="slug"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_SLUG_TT'), '', '', 'COM_JHTRAQ_PROJECT_SLUG'); ?></label></td>
	<td><input type="text" name="slug" id="slug" value="<?php echo @$this->project->slug;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="codename"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_CODENAME_TT'), '', '', 'COM_JHTRAQ_PROJECT_CODENAME'); ?></label></td>
	<td><input type="text" name="codename" id="codename" value="<?php echo @$this->project->codename;?>" class="inputbox" /></td>
</tr>
<tr>
<td width="150"><label for="tags"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_TAGS_TT'), '', '', 'COM_JHTRAQ_PROJECT_TAGS'); ?></label></td>
<td><textarea rows="2" cols="50" name="tags" id="tags" class="inputbox" /><?php echo @$this->project->tags;?></textarea></td>
</tr>
<tr>
	<td width="150"><label for="managers"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_MANAGERS_TT'), '', '', 'COM_JHTRAQ_PROJECT_MANAGERS'); ?></label></td>
	<td><select name="managers[]" id="managers" multiple="multiple" style="width:200px;height:50px;">
	<?php
		$list = explode(",",@$this->project->managers);
		foreach($this->users as $uid=>$uname)
		{
			echo '<option value="'.$uid.'" ';
			if(in_array($uid, $list))
				echo ' Selected ';
			echo '>' . $uname . '</option>';
		}
		?>
	
	</select></td>
</tr>
<tr>
	<td width="150"><label for="svn_url"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_SVN_TT'), '', '', 'COM_JHTRAQ_PROJECT_SVN'); ?></label></td>
	<td><input type="text" name="svn_url" id="svn_url" value="<?php echo @$this->project->svn_url;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="svn_username"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_SVN_USERNAME_TT'), '', '', 'COM_JHTRAQ_PROJECT_SVN_USERNAME'); ?></label></td>
	<td><input type="text" name="svn_username" id="svn_username" value="<?php echo @$this->project->svn_username;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="svn_password"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_SVN_PASSWORD_TT'), '', '', 'COM_JHTRAQ_PROJECT_SVN_PASSWORD'); ?></label></td>
	<td><input type="password" name="svn_password" id="svn_password" value="<?php echo @$this->project->svn_password;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="browse_svn"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_BROWSE_SVN_TT'), '', '', 'COM_JHTRAQ_BROWSE_SVN'); ?></label></td>
	<td><select name="browse_svn[]" id="browse_svn" multiple="multiple" style="width:200px;height:50px;">
	<?php
		$list = explode(",",@$this->project->browse_svn);
		foreach($this->groups as $gid=>$gname)
		{
			echo '<option value="'.$gid.'" ';
			if(in_array($gid, $list))
				echo ' Selected ';
			echo '>' . $gname . '</option>';
		}
		?>
	
	</select></td>
</tr>
<tr>
	<td width="150"><label for="svn_logs"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_BROWSE_SVN_LOGS_TT'), '', '', 'COM_JHTRAQ_BROWSE_SVN_LOGS'); ?></label></td>
	<td><select name="svn_logs[]" id="svn_logs" multiple="multiple" style="width:200px;height:50px;">
	<?php
	$list = explode(",",@$this->project->svn_logs);
	foreach($this->groups as $gid=>$gname)
	{
		echo '<option value="'.$gid.'" ';
		if(in_array($gid, $list))
			echo ' Selected ';
		echo '>' . $gname . '</option>';
	}
	?>
	
	</select></td>
</tr>

<tr>
<td width="150"><label for="add_tickets"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_ADD_TICKETS_TT'), '', '', 'COM_JHTRAQ_ADD_TICKETS'); ?></label></td>
<td><select name="add_tickets[]" id="add_tickets" multiple="multiple" style="width:200px;height:50px;">
	<?php
	$list = explode(",",@$this->project->add_tickets);
	foreach($this->groups as $gid=>$gname)
	{
		echo '<option value="'.$gid.'" ';
		if(in_array($gid, $list))
			echo ' Selected ';
		echo '>' . $gname . '</option>';
	}
	?>
	
	</select></td>
</tr>

<tr>
<td width="150"><label for="amibros_tickets"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_ADD_TICKETS_AMIBROS_TT'), '', '', 'COM_JHTRAQ_ADD_TICKETS_AMIBROS'); ?></label></td>
<td><select name="amibros_tickets[]" id="amibros_tickets" multiple="multiple" style="width:200px;height:50px;">
	<?php
	$list = explode(",",@$this->project->amibros_tickets);
	foreach($this->amibros_tickets() as $gid=>$gname)
	{
		echo '<option value="'.$gid.'" ';
		if(in_array($gid, $list))
			echo ' Selected ';
		echo '>' . $gname . '</option>';
	}
	?>

	</select></td>
</tr>

<tr>
<td width="150"><label for="comment_tickets"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_ADD_TICKET_COMMENTS_TT'), '', '', 'COM_JHTRAQ_ADD_TICKET_COMMENTS'); ?></label></td>
<td><select name="comment_tickets[]" id="comment_tickets" multiple="multiple" style="width:200px;height:50px;">
	<?php
	$list = explode(",",@$this->project->comment_tickets);
	foreach($this->groups as $gid=>$gname)
	{
		echo '<option value="'.$gid.'" ';
		if(in_array($gid, $list))
			echo ' Selected ';
		echo '>' . $gname . '</option>';
	}
	?>
	
	</select></td>
</tr>

<tr>
<td width="150"><label for="edit_wiki"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_EDIT_WIKI_PAGES_TT'), '', '', 'COM_JHTRAQ_EDIT_WIKI_PAGES'); ?></label></td>
<td><select name="edit_wiki[]" id="edit_wiki" multiple="multiple" style="width:200px;height:50px;">
<?php
$list = explode(",",@$this->project->edit_wiki);
foreach($this->groups as $gid=>$gname)
{
	echo '<option value="'.$gid.'" ';
	if(in_array($gid, $list))
		echo ' Selected ';
	echo '>' . $gname . '</option>';
}
?>

</select></td>
</tr>


<tr>
	<td width="150"><label for="info"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_DETAILS_TT'), '', '', 'COM_JHTRAQ_PROJECT_DETAILS'); ?></label></td>
	<td><?php
	// parameters : areaname, content, width, height, cols, rows
	echo $editor->display( 'info',  stripslashes(@$this->project->info), '550', '300', '60', '20', array() ) ;
	?></td>
</tr>
<tr>
	<td width="150"><label for="displayorder"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PROJECT_ORDERING_TT'), '', '', 'COM_JHTRAQ_PROJECT_ORDERING'); ?></label></td>
	<td><input type="text" name="displayorder" id="displayorder" value="<?php echo @$this->project->displayorder;?>" class="inputbox" size="3"/></td>
</tr>
<tr>
	<td width="150"><label for="published"><?php echo JHTML::tooltip(JText::_('COM_JHTRAQ_PUBLISHED_TT'), '', '', 'COM_JHTRAQ_PUBLISHED'); ?></label></td>
	<td><select name="published" id="published">
			<option value="1"><?php echo JText::_('COM_JHTRAQ_YES');?></option>
			<option value="0" <?php if(@!$this->project->published) echo 'Selected';?>><?php echo JText::_('COM_JHTRAQ_NO');?></option>
		</select>
	</td>
</tr>
</table>
</form>
